package com.example.littlepainter.draw.shape

import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF

class StraightLineShape:Shape(){
    override fun containsPoint(x: Float, y: Float): Boolean {
        val slope = (endPoint.y - startPoint.y) / (endPoint.x - startPoint.x)
        val intercept = startPoint.y - slope * startPoint.x
        val expectedY = slope * x + intercept
        return y == expectedY
    }
    override fun drawShape(canvas: Canvas) {
        mPaint.strokeCap = Paint.Cap.ROUND
        canvas.drawLine(startPoint.x,startPoint.y,endPoint.x,endPoint.y,mPaint)
    }
}